
// 376.摆动序列
class Solution {
public:
    int wiggleMaxLength(vector<int>& nums) {
        // 使用贪心的策略
        // 只统计波峰和波谷

        int n = nums.size() , ret = 0;
        int left = 0;
        for(int i = 0 ; i < n - 1 ; i++)
        {
            int right = nums[i + 1] - nums[i];
            if(right == 0) continue;
            if(left * right <= 0) ret++;
            left = right;
        }
        return ret + 1;
    }
};